<%-- 
    Document   : CircleList
    Created on : Dec 6, 2011, 5:53:51 AM
    Author     : Michael
--%>

<%@page import="java.sql.*"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<% if(session.getAttribute("LoggedIn")==null)
       {
    response.sendRedirect("index.html");
    return;
        }

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>All Circles</title>
<script type="text/javascript">

function row_circleclick(txt)
{
    document.forms[txt].submit();
}

function row_mousehover(obj)
{
	obj.style.backgroundColor="#6699FF";
}

function row_mouseout(obj)
{
	obj.style.backgroundColor="";
}
</script>
    </head>
    <body>
        <table width="800" border="0">
            <tr>
                <td><img src="Logo.jpg" width="800" height="150" /></td>
            </tr>

    <tr><td>
            <input type="button" value="Home" onclick="window.location='gohome.jsp'"/>&nbsp;
          <input type="button" value="Log Out" onclick="window.location='logout.jsp'"/><br />
        <table width="800" border="1">
              <tr>
                  <td width="52" />
                  <td>Circle Name</td>
                  <td>Circle Type</td>
                  <td>Circle Owner</td>
                 
              </tr>
          <%
            java.sql.Connection conn = null;
            try
            {
                conn = new DBClasses.GetConnection().getConnection();

                java.sql.Statement stmt = conn.createStatement();
                String query = "SELECT * FROM circle ORDER BY CircleType";
                ResultSet rs = stmt.executeQuery(query);
                int i=0;
                while(rs.next())
                {
                    ResultSet rs1 = conn.createStatement().executeQuery("SELECT Email FROM customer WHERE CustomerID=" + rs.getInt("CircleOwner"));
                    rs1.next();
          %>

        <tr onclick="row_circleclick('<%="circle" + i %>')" onmouseout="row_mouseout(this)" onmouseover="row_mousehover(this)">
            <form name="<%="circle" + i %>" action="CirclePage.jsp" method="post">
            <input name="CIRC" type="hidden" value="<%=rs.getInt("CircleID")%>" />
                <td width="52">
                <img src="CircleLogo.png" alt="" width="52" height="52" />
                </td>
                    <td><label name="circlename" > <%= rs.getString("CircleName") %> </label></td>
                    <td><label name="circletype" > <%= rs.getString("CircleType") %> </label></td>
                    <td><label name="circleowner" > <%= rs1.getString("Email") %> </label></td>
            </form>
            </tr>

                <%
                        i++;
                       }

                  }
                   catch(Exception e)
                   {
                       e.printStackTrace();
                   }
            
                   finally
                   {
                       try{
                       conn.close(); }
                       catch(Exception e) {
                           e.printStackTrace();
                       }
                   }
                %>
        </table>
        </td></tr>
        </table>
    </body>
</html>
